package cap6;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class C extends D implements Serializable {
	private int value;
	private G gvalue;
	private E evalue;

	{
		System.out.println("Se inicializa nueva instancia de C");
	}
	
	public C(){
		{
			System.out.println("Se crea instancia de C por constructor C()");
		}
		this.gvalue = G.ONE;
		this.evalue = new E(5);
	}
	
	public void setValue(int value) {
		this.value = value;
	}

	public int getValue() {
		return value;
	}

	public G getGvalue() {
		return gvalue;
	}

	public void setGvalue(G gvalue) {
		this.gvalue = gvalue;
	}

	public void setEvalue(E evalue) {
		this.evalue = evalue;
	}

	public E getEvalue() {
		return evalue;
	}
	
	private void writeObject(ObjectOutputStream oos) throws IOException{
		oos.writeObject(this.getGvalue());
		oos.writeObject(this.getValue());
		oos.writeInt(this.getEvalue().getValue());
	}
	private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException{
		this.setGvalue((G)ois.readObject());
		this.setValue((Integer)ois.readObject());
		this.evalue = new E(ois.read());
	}

}

enum G {
	ONE, TWO, TREE
}
